/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header: https://192.168.1.224/svn/elancom/product/elancom-platform/trunk/src/main/java/com/elancom/framework/Module.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Id: Module.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Author: lanzhouxue $
 * $Date: 2012-07-02 11:09:12 +0800 (周一, 02 七月 2012) $
 * $Revision: 1034 $
 */
package com.elancom.framework.config;

import java.util.HashMap;
import java.util.Map;

/**
 * @author elancom
 * @date 2012-6-27
 */
public class Module {
	private String code;
	private String name;
	private Module parent = null;
	private final Map<String, Module> children = new HashMap<String, Module>();

	public void addChild(Module module) {
		if (module != null && module.getCode() != null && !module.getCode().trim().isEmpty()) {
			children.put(module.getCode(), module);
		}
	}

	public Module getChild(String code) {
		return children.get(code);
	}

	public String getCode() {
		return code;
	}

	void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	void setName(String name) {
		this.name = name;
	}

	public Module getParent() {
		return parent;
	}

	void setParent(Module parent) {
		this.parent = parent;
	}

	public String getPath() {
		return parent != null ? parent.getPath() + "." + code : code;
	}

	public String getNamePath() {
		return parent != null ? parent.getNamePath() + "." + name : name;
	}
}
